package com.dc.modules.dwr.controller;

import java.util.ArrayList;
import java.util.List;

import org.directwebremoting.annotations.RemoteMethod;
import org.directwebremoting.annotations.RemoteProxy;
import org.springframework.stereotype.Controller;

import com.dc.modules.dwr.domain.Group;
import com.dc.modules.dwr.domain.User;

/*******************************************************************************<P>
 * 文件名: DrwController.java <br>
 * 版本: 1.0<br>
 * 描述:<br>
 * 版权所有: <br>
 * <P>
 * 创建者: 王建栋 <br>
 * 创建日期: 2016年4月19日 上午9:54:50<br>
 * 修改者: <br>
 * 修改日期: <br>
 * 修改说明: <br>
 ******************************************************************************/
@Controller
@RemoteProxy(name="MyDwr")
public class DrwTestController {
	 @RemoteMethod
	  public String hello(String world){
	    
	    System.out.println("hello"+world);
	    
	    return "hello"+world;
	  }
	  
	  @RemoteMethod
	  public User load(){
	    
	    User user=new User(10,"Messi",new Group(1,"Bacelona FC"));
	    
	    return user;
	    
	  }
	  
	  @RemoteMethod
	  public List<User> list(){
	    List<User> users=new ArrayList<User>();
	    users.add(new User(7,"Ronaldo",new Group(3,"Real Madrid")));
	    users.add(new User(11,"Ozil",new Group(8,"Asenal")));
	    users.add(new User(20,"Van Persie",new Group(2,"Manchester United")));
	    users.add(new User(9,"Torress",new Group(5,"Chelsea")));
	    
	    return users;
	  }
	  @RemoteMethod
	  public void add(User user){
	    
	    System.out.println(user);
	  }
	  @RemoteMethod
	  public void deleteUser(){
	    throw new RuntimeException("删除用户！！");
	  }
	  @RemoteMethod
	  public int add(int a,int b){
	    
	    return a+b;
	  }
}
